#app {

  // 主内容区容器的样式
  .main-container {
    min-height: 100%;
    transition: margin-left .28s; // 侧边栏收缩时的过渡效果
    margin-left: 0;
    position: relative;
  }

  // 侧边栏容器的基础样式
  .sidebar-container {
    transition: width 0.28s; // 侧边栏宽度变化的过渡效果
    width: $sideBarWidth !important; // 侧边栏宽度，从变量中获取
    background-color: $menuBg; // 背景色
    height: 100%;
    position: relative;
    font-size: 0px;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1001;
    overflow: hidden;
    box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); // 阴影效果
    border-radius: 8px 0 0 8px; // 左侧圆角
    padding-bottom: 0;

    // 重置Element UI的CSS样式
    .horizontal-collapse-transition {
      transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
    }

    // 滚动条样式设置
    .scrollbar-wrapper {
      overflow-x: hidden !important;
    }

    .el-scrollbar__bar.is-vertical {
      right: 0px;
    }

    .el-scrollbar {
      height: 100%;
    }

    // 当侧边栏有Logo时，调整滚动区域高度
    &.has-logo {
      .el-scrollbar {
        height: calc(100% - 50px);
      }
    }

    // 隐藏水平滚动条
    .is-horizontal {
      display: none;
    }

    // 链接样式
    a {
      display: inline-block;
      width: 100%;
      overflow: hidden;
    }

    // SVG图标样式
    .svg-icon {
      width: 22px;
      height: 22px;
      margin-right: 16px;
      flex-shrink: 0;
    }

    // Element UI图标样式
    .sub-el-icon {
      width: 22px;
      height: 22px;
      margin-right: 12px;
      margin-left: -2px;
      flex-shrink: 0;
    }

    // 菜单样式
    .el-menu {
      border: none;
      height: 100%;
      width: 100% !important;
    }

    // 菜单项悬停效果
    .submenu-title-noDropdown,
    .el-submenu__title {
      &:hover {
        background-color: $menuHover !important;
      }
    }

    // 激活的子菜单标题颜色
    .is-active>.el-submenu__title {
      color: $subMenuActiveText !important;
    }

    // 子菜单项和嵌套菜单样式
    & .nest-menu .el-submenu>.el-submenu__title,
    & .el-submenu .el-menu-item {
      min-width: calc(#{$sideBarWidth} - 50px) !important;
      background-color: $subMenuBg !important;

      &:hover {
        background-color: $subMenuHover !important;
      }
    }

    // 菜单项样式
    .el-menu-item {
      height: 50px;
      line-height: 50px;
      margin: 5px 15px;
      border-radius: 8px; // 圆角菜单项
      padding-right: 20px;
      display: flex;
      align-items: center;
      
      // 图标居中对齐
      .svg-icon, .sub-el-icon {
        display: flex;
        justify-content: center;
        align-items: center;
      }
      
      // 激活菜单项的样式（渐变背景和阴影）
      &.is-active {
        background: linear-gradient(to right, #8a5cff, #6e40ff) !important;
        color: white !important;
        box-shadow: 0 4px 10px rgba(110, 64, 255, 0.3);
      }
    }

    // 子菜单标题样式
    .el-submenu__title {
      display: flex;
      align-items: center;
    }
    
    // 激活父菜单的标题颜色
    .el-submenu.is-active>.el-submenu__title {
      color: $subMenuActiveText !important;
    }

    // 菜单项和子菜单图标间距
    .el-menu-item, .el-submenu__title, .submenu-title-noDropdown {
      .svg-icon, .sub-el-icon {
        margin-right: 12px;
        margin-left: 0;
      }
    }
  }

  // 侧边栏隐藏状态的样式
  .hideSidebar {
    .sidebar-container {
      width: 54px !important; // 折叠状态下的宽度
      
      // 折叠状态下的图标样式（居中显示）
      .svg-icon, .sub-el-icon {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: 100% !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;

        svg {
          width: 22px !important;
          height: 22px !important;
        }
      }
      
      // 折叠状态下的菜单项样式
      .el-menu-item, 
      .el-submenu__title,
      .submenu-title-noDropdown {
        padding: 0 !important;
        text-align: center;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        margin: 8px auto !important;
        width: 40px !important;
        height: 40px !important;
        line-height: 40px !important;
        border-radius: 8px !important;
        position: relative !important;
        
        // 图标在折叠状态下居中显示
        i, .svg-icon {
          position: absolute !important;
          top: 50% !important;
          left: 50% !important;
          transform: translate(-50%, -50%) !important;
          margin: 0 !important;
          padding: 0 !important;
          width: 100% !important;
          height: 100% !important;
        }
      }
      
      // 首页和聊天室图标的特殊样式
      .icon-home, .icon-chat {
        svg {
          width: 18px !important;
          height: 18px !important;
        }
      }
    }

    // 折叠状态下主容器无左边距
    .main-container {
      margin-left: 0;
    }

    // 无下拉菜单的标题样式（折叠状态）
    .submenu-title-noDropdown {
      padding: 0 !important;
      position: relative;
      text-align: center;

      .el-tooltip {
        padding: 0 !important;
        display: flex;
        justify-content: center;

        .svg-icon {
          margin-left: 0;
        }

        .sub-el-icon {
          margin-left: 0;
        }
      }
    }

    // 子菜单样式（折叠状态）
    .el-submenu {
      overflow: hidden;

      &>.el-submenu__title {
        padding: 0 !important;
        text-align: center;
        display: flex;
        justify-content: center;

        .svg-icon {
          margin-left: 0;
        }

        .sub-el-icon {
          margin-left: 0;
        }

        // 隐藏子菜单箭头
        .el-submenu__icon-arrow {
          display: none;
        }
      }
    }

    // 折叠的菜单样式
    .el-menu--collapse {
      .el-submenu {
        &>.el-submenu__title {
          &>span {
            height: 0;
            width: 0;
            overflow: hidden;
            visibility: hidden;
            display: inline-block;
          }
        }
      }
    }
  }

  .el-menu--collapse .el-menu .el-submenu {
    min-width: $sideBarWidth !important;
  }

  // mobile responsive
  .mobile {
    .main-container {
      margin-left: 0px;
    }

    .sidebar-container {
      transition: transform .28s;
      width: $sideBarWidth !important;
    }

    &.hideSidebar {
      .sidebar-container {
        pointer-events: none;
        transition-duration: 0.3s;
        transform: translate3d(-$sideBarWidth, 0, 0);
      }
    }
  }

  .withoutAnimation {

    .main-container,
    .sidebar-container {
      transition: none;
    }
  }
}

// when menu collapsed
.el-menu--vertical {
  &>.el-menu {
    .svg-icon {
      margin-right: 16px;
    }
    .sub-el-icon {
      margin-right: 12px;
      margin-left: -2px;
    }
  }

  .nest-menu .el-submenu>.el-submenu__title,
  .el-menu-item {
    &:hover {
      // you can use $subMenuHover
      background-color: $menuHover !important;
    }
  }

  // the scroll bar appears when the subMenu is too long
  >.el-menu--popup {
    max-height: 100vh;
    overflow-y: auto;

    &::-webkit-scrollbar-track-piece {
      background: #d3dce6;
    }

    &::-webkit-scrollbar {
      width: 6px;
    }

    &::-webkit-scrollbar-thumb {
      background: #99a9bf;
      border-radius: 20px;
    }
  }
}

// 弹出菜单的样式
.el-menu--vertical:not(.el-menu--collapse) {
  .el-menu--popup {
    min-width: 200px !important;
    
    .el-menu-item {
      display: flex !important;
      align-items: center !important;
      height: 40px !important;
      line-height: 40px !important;
      margin: 4px 8px !important;
      border-radius: 8px !important;
      padding: 0 20px !important;
      
      &.is-active {
        background: linear-gradient(to right, #8a5cff, #6e40ff) !important;
        color: white !important;
      }
    }
  }
}
